<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>显示全部站点</title>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.4"></script>
<style>
html{height:100%;}
body{height:100%;margin:0px;padding:0px;}
#icon{height:100%;}
</style>
</head>

<body>

<div id="icon"></div>
<script>
var map = new BMap.Map('icon'); 
var point = new BMap.Point(121.30, 31.15); 
map.centerAndZoom(point, 15);
map.addControl(new BMap.NavigationControl()); //开启百度平移缩放控件
map.addControl(new BMap.OverviewMapControl()); //开启百度缩略滴入控件
map.addControl(new BMap.MapTypeControl()); //开启百度地图类型控件
map.addControl(new BMap.CopyrightControl()); //开启百度版权控件

map.enableScrollWheelZoom();    //启用滚轮放大缩小，默认禁用
map.enableContinuousZoom();    //启用地图惯性拖拽，默认禁用

function SquareOverlay(center){  
 this._center = center;
 this.width = 32;
 this.height = 32;
}  
// 继承API的BMap.Overlay  
SquareOverlay.prototype = new BMap.Overlay(); 
SquareOverlay.prototype.initialize = function(map){  
// 保存map对象实例  
 this._map = map;      
 // 创建div元素，作为自定义覆盖物的容器  
 var div = document.createElement("div");  
 div.style.position = "absolute";      
 // 可以根据参数设置元素外观  
 div.style.width = this.width + "px";  
 div.style.height = this.height + "px";  
 div.style.background = "url('<?=BASE_URL.'/imgs/maker2.gif'?>')";    
 // 将div添加到覆盖物容器中  
 map.getPanes().markerPane.appendChild(div);    
 // 保存div实例  
 this._div = div;    
 // 需要将div元素作为方法的返回值，当调用该覆盖物的show、  
 // hide方法，或者对覆盖物进行移除时，API都将操作此元素。  
 return div;  
}
// 实现绘制方法  
SquareOverlay.prototype.draw = function(){  
// 根据地理坐标转换为像素坐标，并设置给容器  
 var position = this._map.pointToOverlayPixel(this._center);  
 this._div.style.left = position.x - this.width / 2 + "px";  
 this._div.style.top = position.y - this.height / 2 + "px";  
}
SquareOverlay.prototype.show = function(){  
 if (this._div){  
   this._div.style.display = "";  
 }  
}    
// 实现隐藏方法  
SquareOverlay.prototype.hide = function(){  
 if (this._div){  
   this._div.style.display = "none";  
 }  
}


//function addPoint(point){
function addPoint(x,y){
	var point = new BMap.Point(x,y);  
	map.centerAndZoom(point, 15);
	// 添加自定义覆盖物  
	var mySquare = new SquareOverlay(map.getCenter());  
	map.addOverlay(mySquare);
}

//var T_address = document.getElementById('address');
//var B_search = document.getElementById('search');
//
//B_search.onclick = function(){
//	var value = T_address.value;
//	if(value){
//		var myGeo = new BMap.Geocoder();
//		// 将地址解析结果显示在地图上,并调整地图视野
//		myGeo.getPoint(value, function(point){
//		  if (point) {
//			addPoint(point);
//		  }
//		});
//	}else alert('请输入内容!');
//}

var points = new Array(
<?php 
$common = '';
foreach($client as $arr){ 
?>
	<?php echo $common;?> new Array('<?=$arr['lng']?>', '<?=$arr['lat']?>')
	
<?php 
	if(empty($common)){ $common = ','; }
}?>
);
for(var i=0; i<<?=$count?>; i++){
	addPoint(points[i][0], points[i][1]);
}

</script>
</body>
</html>
